import React, { useEffect } from 'react';
import * as echarts from 'echarts';
import "./index.scss"

const LineChart = () => {   
    var main3: any = null;
    useEffect(() => {
        main3 = initEcharts('main3', '', [], []);
    }, [])
    var initEcharts = (dom: any, title: any, xAxis: any, series: any) => {

        var myChart = echarts.init(document.getElementById(dom) || document.body);
        const month = ['6/16', '6/17', '6/18', '6/19', '6/20', '6/21', '6/22', '6/23'];
        const dateList = month.map(function (item) {
            return item[0];
        });
        myChart.setOption({
            visualMap: [
                {
                    show: false,
                    type: 'continuous',
                    seriesIndex: 0,
                    min: 0,
                    max: 400
                },
                {
                    show: false,
                    type: 'continuous',
                    seriesIndex: 1,
                    dimension: 0,
                    min: 0,
                    max: dateList.length - 1
                }
            ],
            title: {
                text: '日活趋势'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data: ['平日生活']
            },
            xAxis: {
                type: 'category',
                // boundaryGap: false,
                data: month
            },
            yAxis: {
                type: `value`
            },
            series: [
                {
                    name: '平日生活',
                    type: 'line',
                    showSymbol: false,
                    data: [190, 100, 191, 134, 200, 130, 250, 100]
                }
            ]
        });
        return myChart;
    }
    return (
        <div className='linechart'>
            <div id="main3">

            </div>
        </div>
    );
};

export default LineChart;